﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.IO;
using EnvDTE;

namespace DPMP.ViewModel
{
    public static class Service
    {
        public static string GetFullPath(string relativePath)
        {
            // get application data folder path
            string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            // create the full path from relative path
            string fullPath = Path.Combine(appDataPath, relativePath);

            // return the full path
            return fullPath;
        }

        public static void OpenFile(string fileName)
        {
            // get the current Visual Studio instance
            var dte = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.10.0");
            var itemOp = dte.ItemOperations;

            // get the full path of the file name
            var fullPath = GetFullPath(fileName);

            // open the file name
            itemOp.OpenFile(fullPath, EnvDTEConstants.vsViewKindTextView);
        }
    }
}
